package org.sith.taskrunner.gwt.client.widgets;

import com.google.gwt.core.client.GWT;
import com.google.gwt.editor.client.Editor;
import com.google.gwt.editor.client.SimpleBeanEditorDriver;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import org.sith.taskrunner.gwt.shared.domains.RunTaskData;


public class RunTaskWidgetEditor extends Composite implements Editor<RunTaskData> {

    private Driver driver;

    interface RunTaskWidgetUiBinder extends UiBinder<HTMLPanel, RunTaskWidgetEditor> {
    }

    interface Driver extends SimpleBeanEditorDriver<RunTaskData, RunTaskWidgetEditor> {
    }


    private static RunTaskWidgetUiBinder ourUiBinder = GWT.create(RunTaskWidgetUiBinder.class);
    @UiField
    TaskWrapperSelectorWidget wrappersEditor;

    public RunTaskWidgetEditor() {
        initWidget(ourUiBinder.createAndBindUi(this));
        driver = GWT.create(Driver.class);
    }

    public void edit(RunTaskData runTaskData) {

        driver.initialize(this);

        driver.edit(runTaskData);

    }

    /* // Called by some UI action
    public void save() {
        Person edited = driver.flush();
        if (driver.hasErrors()) {
            // A sub-editor reported errors
        }
        doSomethingWithEditedPerson(edited);
    }*/
}